<template>
	<view class="myAppraise">
		<view class="myAppraise-tabs">
			<u-tabs :list="list"  :is-scroll="false" :current="current" @change="change" active-color="#D1AA56"></u-tabs>
		</view>
		<view class="myAppraise-plate-1">
			<view class="item" v-for="(item,index) in pageData" :key="index">
				<view class="item-top">
					<view class="user-info">
						<image :src="item.head_pic" mode=""></image>
						<text>{{item.nickname}}</text>
					</view>
					<u-icon name="more-dot-fill" color="#aaaaaa" size="34"  @click="onDeteleBtn(item.is_detele,index)"></u-icon>
				</view>
				<view class="item-btm">
					<view class="content">
						{{item.evaluate_content}}
					</view>
					<view class="img-list">
						<image :src="i" mode="" v-for="(i,num) in item.evaluate_pic" :key="index"></image>
					</view>
				</view>
				<view class="goods-list">
					<view class="goods-item">
						<image :src="item.goods_pic" mode=""></image>
						<view class="goods-item-right">
							<view class="goods-name">
								{{item.goods_name}}
							</view>
							<view class="goods-price">
								<text>¥{{item.sub_prices}}</text>
								<text v-if="item.overall_evaluate == 3">已好评</text>
								<text v-if="item.overall_evaluate == 2">已中评</text>
								<text v-if="item.overall_evaluate == 2">已差评</text>
							</view>
						</view>
					</view>
				</view>
				<view class="look">
					<text>浏览{{item.watch_num}}</text>
				</view>
				<view class="detele-box" v-show="item.is_detele" @click="onDelete(item.order_evaluate_id,index)">
					删除评价
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				list:[
					{
						name:'订单评价'
					},
					{
						name:'鉴定师评价'
					}
				],
				page:1,
				pageData:[]
				
			};
		},
		created() {
			this.getPageData()
		},
		onReachBottom() {
			this.page ++
			this.getPageData()
		},
		methods:{
			// 删除评价
			onDelete(id,index){
				uni.request({
				    url:this.$Url +'/index.php/App/Order/delOrderEvaluate',
				    method:'POST',
				    data:{
						order_evaluate_id:id
				    },
				    header:{
				        "token":uni.getStorageSync('token')
				    },
				    success: (res) => {
						if (res.data.status == 200) {
							let arr = this.pageData
							arr.splice(index,1)
							this.pageData = arr
							uni.showToast({
								title:'删除成功',
								icon:'none',
								duration:1200
							})
						} else{
							uni.showToast({
								title:res.data.msg,
								icon:'none',
								duration:1200
							})
						}
				    }
				})
			},
			// 操作删除按钮
			onDeteleBtn(is_detele,index){
				if (is_detele == false) {
					this.pageData[index].is_detele = true
				} else{
					this.pageData[index].is_detele = false
				}
			},
			// tabs切换
			change(index) {
				this.page = 1
				this.pageData = []
				this.current = index;
				if (this.current == 0) {
					this.getPageData()
				} else{
					console.log('没有页面暂未开发')
				}
			},
			// 请求评价列表
			getPageData(){
				uni.request({
				    url:this.$Url +'/index.php/App/Order/evaluateList',
				    method:'POST',
				    data:{
				       p:this.page
				    },
				    header:{
				        "token":uni.getStorageSync('token')
				    },
				    success: (res) => {
						if (res.data.status == 200) {
							this.pageData = this.pageData.concat(res.data.data.evaluate_list)
						} else{
							uni.showToast({
								title:res.data.msg,
								icon:'none',
								duration:1200
							})
						}
				    }
				})
			}
		}
	}
</script>

<style lang="scss" scoped> 
.myAppraise{
	width: 100vw;
	min-height: 100vh;
	background-color: #f7f7f7;
	.pmyAppraise-tabs{
		background-color: #fff;
		padding-top: 10upx;
		padding-bottom: 10upx;
		position: fixed;
		width: 100%;
		z-index: 100;
	}
	.myAppraise-plate-1{
		padding-bottom: 100upx;
		.item{
			width: 100vw;
			background-color: #fff;
			padding: 20upx;
			margin-top: 15upx;
			position: relative;
			.item-top{
				display: flex;
				align-items: center;
				justify-content: space-between;
				.user-info{
					display: flex;
					image{
						width: 63upx;
						height: 63upx;
						border-radius: 50%;
						margin-right: 20upx;
					}
					text{
						font-size: 26upx;
						color: #333;
					}
				}
			}
			.item-btm{
				margin-top: 20upx;
				.content{
					font-size: 26upx;
					color: #555;
					margin-bottom: 40upx;
				}
				.img-list{
					display: flex;
					flex-wrap: wrap;
					align-items: center;
					image{
						width: 143upx;
						height: 143upx;
						margin-right: 30upx;
						margin-bottom: 20upx;
					}
				}
			}
			.goods-list{
				padding-top: 30upx;
				.goods-item{
					width: 100%;
					height: 145upx;
					background-color: #f7f7f7;
					display: flex;
					align-items: center;
					image{
						width: 143upx;
						height: 143upx;
						margin-right: 20upx;
					}
					.goods-item-right{
						width: 500upx;
						.goods-name{
							font-size: 24upx;
							color: #333;
							margin-bottom: 20upx;
						}
						.goods-price{
							display: flex;
							align-items: center;
							text:first-child{
								font-size: 26upx;
								color: #333;
								margin-right: 40upx;
							}
							text:last-child{
								color: $zhuti-color;
								font-size: 30upx;
							}
						}
					}
				}
			}
			.look{
				height: 60upx;
				display: flex;
				align-items: center;
				text{
					font-size: 24upx;
					color: #999;
					margin-top: 20upx;
				}
			}
			.detele-box{
				position: absolute;
				top: 80upx;
				right: 30upx;
				padding: 20upx 30upx;
				background-color: #fff;
				box-shadow: 0upx 0upx 6upx rgba(0,0,0,0.2);
				z-index: 100;
				font-size: 24upx;
			}
		}
	}
}
</style>
